local key = KEYS[1]
local value = ARGV[1]
local ttl = ARGV[2]

local ok = redis.call('setnx',key,value)
if ok == 1 then
    return tostring(redis.call('expire', key, ttl))
end
return "0"